!function(e,t,n){function r(e,t){return typeof e===t}function o(){var e,t,n,o,i,a,s;for(var u in S)if(S.hasOwnProperty(u)){if(e=[],t=S[u],t.name&&(e.push(t.name.toLowerCase()),t.options&&t.options.aliases&&t.options.aliases.length))for(n=0;nd;d++)if(m=e[d],v=D.style[m],c(m,"-")&&(m=s(m)),D.style[m]!==n){if(i||r(o,"undefined"))return a(),"pfx"==t?m:!0;try{D.style[m]=o}catch(y){}if(D.style[m]!=v)return a(),"pfx"==t?m:!0}return a(),!1}function g(e,t,n,o,i){var a=e.charAt(0).toUpperCase()+e.slice(1),s=(e+" "+F.join(a+" ")+a).split(" ");return r(t,"string")||r(t,"undefined")?v(s,t,o,i):(s=(e+" "+T.join(a+" ")+a).split(" "),p(s,t,n))}function y(e,t,r){return g(e,n,n,t,r)}var C=[],S=[],x={_version:"3.3.1",_config:{classPrefix:"",enableClasses:!0,enableJSClass:!0,usePrefixes:!0},_q:[],on:function(e,t){var n=this;setTimeout(function(){t(n[e])},0)},addTest:function(e,t,n){S.push({name:e,fn:t,options:n})},addAsyncTest:function(e){S.push({name:null,fn:e})}},Modernizr=function(){};Modernizr.prototype=x,Modernizr=new Modernizr;var _=x._config.usePrefixes?" -webkit- -moz- -o- -ms- ".split(" "):["",""];x._prefixes=_;var b=t.documentElement,w="svg"===b.nodeName.toLowerCase();w||!function(e,t){function n(e,t){var n=e.createElement("p"),r=e.getElementsByTagName("head")[0]||e.documentElement;return n.innerHTML="x",r.insertBefore(n.lastChild,r.firstChild)}function r(){var e=C.elements;return"string"==typeof e?e.split(" "):e}function o(e,t){var n=C.elements;"string"!=typeof n&&(n=n.join(" ")),"string"!=typeof e&&(e=e.join(" ")),C.elements=n+" "+e,l(t)}function i(e){var t=y[e[v]];return t||(t={},g++,e[v]=g,y[g]=t),t}function a(e,n,r){if(n||(n=t),c)return n.createElement(e);r||(r=i(n));var o;return o=r.cache[e]?r.cache[e].cloneNode():h.test(e)?(r.cache[e]=r.createElem(e)).cloneNode():r.createElem(e),!o.canHaveChildren||m.test(e)||o.tagUrn?o:r.frag.appendChild(o)}function s(e,n){if(e||(e=t),c)return e.createDocumentFragment();n=n||i(e);for(var o=n.frag.cloneNode(),a=0,s=r(),u=s.length;u>a;a++)o.createElement(s[a]);return o}function u(e,t){t.cache||(t.cache={},t.createElem=e.createElement,t.createFrag=e.createDocumentFragment,t.frag=t.createFrag()),e.createElement=function(n){return C.shivMethods?a(n,e,t):t.createElem(n)},e.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+r().join().replace(/[\w\-:]+/g,function(e){return t.createElem(e),t.frag.createElement(e),'c("'+e+'")'})+");return n}")(C,t.frag)}function l(e){e||(e=t);var r=i(e);return!C.shivCSS||f||r.hasCSS||(r.hasCSS=!!n(e,"article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}mark{background:#FF0;color:#000}template{display:none}")),c||u(e,r),e}var f,c,d="3.7.3",p=e.html5||{},m=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,h=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,v="_html5shiv",g=0,y={};!function(){try{var e=t.createElement("a");e.innerHTML="",f="hidden"in e,c=1==e.childNodes.length||function(){t.createElement("a");var e=t.createDocumentFragment();return"undefined"==typeof e.cloneNode||"undefined"==typeof e.createDocumentFragment||"undefined"==typeof e.createElement}()}catch(n){f=!0,c=!0}}();var C={elements:p.elements||"abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output picture progress section summary template time video",version:d,shivCSS:p.shivCSS!==!1,supportsUnknownElements:c,shivMethods:p.shivMethods!==!1,type:"default",shivDocument:l,createElement:a,createDocumentFragment:s,addElements:o};e.html5=C,l(t),"object"==typeof module&&module.exports&&(module.exports=C)}("undefined"!=typeof e?e:this,t);var E="Moz O ms Webkit",T=x._config.usePrefixes?E.toLowerCase().split(" "):[];x._domPrefixes=T;var z;!function(){var e={}.hasOwnProperty;z=r(e,"undefined")||r(e.call,"undefined")?function(e,t){return t in e&&r(e.constructor.prototype[t],"undefined")}:function(t,n){return e.call(t,n)}}(),x._l={},x.on=function(e,t){this._l[e]||(this._l[e]=[]),this._l[e].push(t),Modernizr.hasOwnProperty(e)&&setTimeout(function(){Modernizr._trigger(e,Modernizr[e])},0)},x._trigger=function(e,t){if(this._l[e]){var n=this._l[e];setTimeout(function(){var e,r;for(e=0;e=7)}),Modernizr.addTest("touchevents",function(){var n;if("ontouchstart"in e||e.DocumentTouch&&t instanceof DocumentTouch)n=!0;else{var r=["@media (",_.join("touch-enabled),("),"heartz",")","{#modernizr{top:9px;position:absolute}}"].join("");k(r,function(e){n=9===e.offsetTop})}return n});var F=x._config.usePrefixes?E.split(" "):[];x._cssomPrefixes=F;var M=function(t){var r,o=_.length,i=e.CSSRule;if("undefined"==typeof i)return n;if(!t)return!1;if(t=t.replace(/^@/,""),r=t.replace(/-/g,"_").toUpperCase()+"_RULE",r in i)return"@"+t;for(var a=0;o>a;a++){var s=_[a],u=s.toUpperCase()+"_"+r;if(u in i)return"@-"+s.toLowerCase()+"-"+t}return!1};x.atRule=M;var L={elem:u("modernizr")};Modernizr._q.push(function(){delete L.elem});var D={style:L.elem.style};Modernizr._q.unshift(function(){delete D.style});x.testProp=function(e,t,r){return v([e],n,t,r)};x.testAllProps=g;x.prefixed=function(e,t,n){return 0===e.indexOf("@")?M(e):(-1!=e.indexOf("-")&&(e=s(e)),t?g(e,t,n):g(e,"pfx"))};x.testAllProps=y,Modernizr.addTest("overflowscrolling",y("overflowScrolling","touch",!0)),Modernizr.addTest("csstransforms",function(){return-1===navigator.userAgent.indexOf("Android 2.")&&y("transform","scale(1)",!0)}),Modernizr.addTest("csstransforms3d",function(){var e=!!y("perspective","1px",!0),t=Modernizr._config.usePrefixes;if(e&&(!t||"webkitPerspective"in b.style)){var n,r="#modernizr{width:0;height:0}";Modernizr.supports?n="@supports (perspective: 1px)":(n="@media (transform-3d)",t&&(n+=",(-webkit-transform-3d)")),n+="{#modernizr{width:7px;height:18px;margin:0;padding:0;border:0}}",k(r+n,function(t){e=7===t.offsetWidth&&18===t.offsetHeight})}return e}),o(),i(C),delete x.addTest,delete x.addAsyncTest;for(var O=0;O0},e.prototype.next=function(){return this.hasNext()?this.run(this.context.nextUrl):!1},e.prototype.run=function(t){var n,r,i;if(typeof this.options.clientId!="string"&&typeof this.options.accessToken!="string")throw new Error("Missing clientId or accessToken.");if(typeof this.options.accessToken!="string"&&typeof this.options.clientId!="string")throw new Error("Missing clientId or accessToken.");return this.options.before!=null&&typeof this.options.before=="function"&&this.options.before.call(this),typeof document!="undefined"&&document!==null&&(i=document.createElement("script"),i.id="instafeed-fetcher",i.src=t||this._buildUrl(),n=document.getElementsByTagName("head"),n[0].appendChild(i),r="instafeedCache"+this.unique,window[r]=new e(this.options,this),window[r].unique=this.unique),!0},e.prototype.parse=function(e){var t,n,r,i,s,o,u,a,f,l,c,h,p,d,v,m,g,y,b,w,E,S;if(typeof e!="object"){if(this.options.error!=null&&typeof this.options.error=="function")return this.options.error.call(this,"Invalid JSON data"),!1;throw new Error("Invalid JSON response")}if(e.meta.code!==200){if(this.options.error!=null&&typeof this.options.error=="function")return this.options.error.call(this,e.meta.error_message),!1;throw new Error("Error from Instagram: "+e.meta.error_message)}if(e.data.length===0){if(this.options.error!=null&&typeof this.options.error=="function")return this.options.error.call(this,"No images were returned from Instagram"),!1;throw new Error("No images were returned from Instagram")}this.options.success!=null&&typeof this.options.success=="function"&&this.options.success.call(this,e),this.context.nextUrl="",e.pagination!=null&&(this.context.nextUrl=e.pagination.next_url);if(this.options.sortBy!=="none"){this.options.sortBy==="random"?d=["","random"]:d=this.options.sortBy.split("-"),p=d[0]==="least"?!0:!1;switch(d[1]){case"random":e.data.sort(function(){return.5-Math.random()});break;case"recent":e.data=this._sortBy(e.data,"created_time",p);break;case"liked":e.data=this._sortBy(e.data,"likes.count",p);break;case"commented":e.data=this._sortBy(e.data,"comments.count",p);break;default:throw new Error("Invalid option for sortBy: '"+this.options.sortBy+"'.")}}if(typeof document!="undefined"&&document!==null&&this.options.mock===!1){a=e.data,this.options.limit!=null&&a.length>this.options.limit&&(a=a.slice(0,this.options.limit+1||9e9)),n=document.createDocumentFragment(),this.options.filter!=null&&typeof this.options.filter=="function"&&(a=this._filter(a,this.options.filter));if(this.options.template!=null&&typeof this.options.template=="string"){i="",o="",l="",v=document.createElement("div");for(m=0,b=a.length;ms?1:-1:i=0?u:o+u;var a=n?n:o;if(n<0){a=o+n}s=a-u;if(s>0){i=new Array(s);if(this.charAt){for(r=0;r320&&feedWidth<480)&&sbiWindowWidth<480)colWidth=480;if(feedWidth<320&&sbiWindowWidth<480)colWidth=300} if(colWidth<150){imgRes='thumbnail'}else if(colWidth<320){imgRes='low_resolution'}else{imgRes='standard_resolution'} if(feedWidth<=100)imgRes='low_resolution';break;case 'thumb':imgRes='thumbnail';break;case 'medium':imgRes='low_resolution';break;default:imgRes='standard_resolution'} var ids_arr=user_id.replace(/ /g,'').split(",");var looparray=ids_arr;var headerStyles='',sbi_page_url='https://api.instagram.com/v1/users/'+ids_arr[0]+'?access_token='+sb_instagram_js_options.sb_instagram_at;if(feedOptions.headercolor.length)headerStyles='style="color: #'+feedOptions.headercolor+'"';jQuery.ajax({method:"GET",url:sbi_page_url,dataType:"jsonp",success:function(data){$header='';$header+='
';$header+='

';if(data.data.bio.length)$header+='

'+data.data.bio+'

';$header+='

';$header+='
';$header+='
';$header+=''+data.data.full_name+'';$header+='
';$header+='
';$self.find('.sb_instagram_header').prepend($header);if($self.find('.sbi_follow_btn').length)$self.find('.sbi_follow_btn a').attr('href','http://instagram.com/'+data.data.username)}});jQuery.each(looparray,function(index,entry){var userFeed=new instagramfeed({target:$target,get:getType,sortBy:sortby,resolution:imgRes,limit:parseInt(num,10),template:'
{{caption}}
',filter:function(image){var date=new Date(image.created_time*1000),time=date.getTime();image.created_time_raw=time;if(image.caption!=null)image.caption.text=image.caption.text.replace(/[^a-zA-Z ]/g,"");image.images.thumbnail.url=image.images.thumbnail.url.split("?ig_cache_key")[0];image.images.standard_resolution.url=image.images.standard_resolution.url.split("?ig_cache_key")[0];image.images.low_resolution.url=image.images.low_resolution.url.split("?ig_cache_key")[0];return !0},userId:parseInt(entry,10),accessToken:sb_instagram_js_options.sb_instagram_at,after:function(){$self.find('.sbi_loader').remove();if(this.hasNext())morePosts.push('1');if(morePosts.length>0){$loadBtn.show()}else{$loadBtn.hide();$self.css('padding-bottom',0)} if(typeof sbi_custom_js=='function')setTimeout(function(){sbi_custom_js()},100);if(imgRes!=='thumbnail'){var sbi_imgLiquid=sbi_imgLiquid||{VER:"0.9.944"};sbi_imgLiquid.bgs_Available=!1,sbi_imgLiquid.bgs_CheckRunned=!1,function(i){function t(){if(!sbi_imgLiquid.bgs_CheckRunned){sbi_imgLiquid.bgs_CheckRunned=!0;var t=i('');i("body").append(t),!function(){var i=t[0];if(i&&window.getComputedStyle){var e=window.getComputedStyle(i,null);e&&e.backgroundSize&&(sbi_imgLiquid.bgs_Available="cover"===e.backgroundSize)}}(),t.remove()}}i.fn.extend({sbi_imgLiquid:function(e){this.defaults={fill:!0,verticalAlign:"center",horizontalAlign:"center",useBackgroundSize:!0,useDataHtmlAttr:!0,responsive:!0,delay:0,fadeInTime:0,removeBoxBackground:!0,hardPixels:!0,responsiveCheckTime:500,timecheckvisibility:500,onStart:null,onFinish:null,onItemStart:null,onItemFinish:null,onItemError:null},t();var a=this;return this.options=e,this.settings=i.extend({},this.defaults,this.options),this.settings.onStart&&this.settings.onStart(),this.each(function(t){function e(){-1===u.css("background-image").indexOf(encodeURI(c.attr("src")))&&u.css({"background-image":'url("'+encodeURI(c.attr("src"))+'")'}),u.css({"background-size":g.fill?"cover":"contain","background-position":(g.horizontalAlign+" "+g.verticalAlign).toLowerCase(),"background-repeat":"no-repeat"}),i("a:first",u).css({display:"block",width:"100%",height:"100%"}),i("img",u).css({display:"none"}),g.onItemFinish&&g.onItemFinish(t,u,c),u.addClass("sbi_imgLiquid_bgSize"),u.addClass("sbi_imgLiquid_ready"),l()}function o(){function e(){c.data("sbi_imgLiquid_error")||c.data("sbi_imgLiquid_loaded")||c.data("sbi_imgLiquid_oldProcessed")||(u.is(":visible")&&c[0].complete&&c[0].width>0&&c[0].height>0?(c.data("sbi_imgLiquid_loaded",!0),setTimeout(r,t*g.delay)):setTimeout(e,g.timecheckvisibility))}if(c.data("oldSrc")&&c.data("oldSrc")!==c.attr("src")){var a=c.clone().removeAttr("style");return a.data("sbi_imgLiquid_settings",c.data("sbi_imgLiquid_settings")),c.parent().prepend(a),c.remove(),c=a,c[0].width=0,void setTimeout(o,10)}return c.data("sbi_imgLiquid_oldProcessed")?void r():(c.data("sbi_imgLiquid_oldProcessed",!1),c.data("oldSrc",c.attr("src")),i("img:not(:first)",u).css("display","none"),u.css({overflow:"hidden"}),c.fadeTo(0,0).removeAttr("width").removeAttr("height").css({visibility:"visible","max-width":"none","max-height":"none",width:"auto",height:"auto",display:"block"}),c.on("error",n),c[0].onerror=n,e(),void d())}function d(){(g.responsive||c.data("sbi_imgLiquid_oldProcessed"))&&c.data("sbi_imgLiquid_settings")&&(g=c.data("sbi_imgLiquid_settings"),u.actualSize=u.get(0).offsetWidth+u.get(0).offsetHeight/1e4,u.sizeOld&&u.actualSize!==u.sizeOld&&r(),u.sizeOld=u.actualSize,setTimeout(d,g.responsiveCheckTime))}function n(){c.data("sbi_imgLiquid_error",!0),u.addClass("sbi_imgLiquid_error"),g.onItemError&&g.onItemError(t,u,c),l()}function s(){var i={};if(a.settings.useDataHtmlAttr){var t=u.attr("data-sbi_imgLiquid-fill"),e=u.attr("data-sbi_imgLiquid-horizontalAlign"),o=u.attr("data-sbi_imgLiquid-verticalAlign");("true"===t||"false"===t)&&(i.fill=Boolean("true"===t)),void 0===e||"left"!==e&&"center"!==e&&"right"!==e&&-1===e.indexOf("%")||(i.horizontalAlign=e),void 0===o||"top"!==o&&"bottom"!==o&&"center"!==o&&-1===o.indexOf("%")||(i.verticalAlign=o)}return sbi_imgLiquid.isIE&&a.settings.ieFadeInDisabled&&(i.fadeInTime=0),i}function r(){var i,e,a,o,d,n,s,r,m=0,h=0,f=u.width(),v=u.height();void 0===c.data("owidth")&&c.data("owidth",c[0].width),void 0===c.data("oheight")&&c.data("oheight",c[0].height),g.fill===f/v>=c.data("owidth")/c.data("oheight")?(i="100%",e="auto",a=Math.floor(f),o=Math.floor(f*(c.data("oheight")/c.data("owidth")))):(i="auto",e="100%",a=Math.floor(v*(c.data("owidth")/c.data("oheight"))),o=Math.floor(v)),d=g.horizontalAlign.toLowerCase(),s=f-a,"left"===d&&(h=0),"center"===d&&(h=.5*s),"right"===d&&(h=s),-1!==d.indexOf("%")&&(d=parseInt(d.replace("%",""),10),d>0&&(h=s*d*.01)),n=g.verticalAlign.toLowerCase(),r=v-o,"left"===n&&(m=0),"center"===n&&(m=.5*r),"bottom"===n&&(m=r),-1!==n.indexOf("%")&&(n=parseInt(n.replace("%",""),10),n>0&&(m=r*n*.01)),g.hardPixels&&(i=a,e=o),c.css({width:i,height:e,"margin-left":Math.floor(h),"margin-top":Math.floor(m)}),c.data("sbi_imgLiquid_oldProcessed")||(c.fadeTo(g.fadeInTime,1),c.data("sbi_imgLiquid_oldProcessed",!0),g.removeBoxBackground&&u.css("background-image","none"),u.addClass("sbi_imgLiquid_nobgSize"),u.addClass("sbi_imgLiquid_ready")),g.onItemFinish&&g.onItemFinish(t,u,c),l()}function l(){t===a.length-1&&a.settings.onFinish&&a.settings.onFinish()}var g=a.settings,u=i(this),c=i("img:first",u);return c.length?(c.data("sbi_imgLiquid_settings")?(u.removeClass("sbi_imgLiquid_error").removeClass("sbi_imgLiquid_ready"),g=i.extend({},c.data("sbi_imgLiquid_settings"),a.options)):g=i.extend({},a.settings,s()),c.data("sbi_imgLiquid_settings",g),g.onItemStart&&g.onItemStart(t,u,c),void(sbi_imgLiquid.bgs_Available&&g.useBackgroundSize?e():o())):void n()})}})}(jQuery);!function(){var css=sbi_imgLiquid.injectCss,head=document.getElementsByTagName('head')[0],style=document.createElement('style');style.type='text/css';if(style.styleSheet){style.styleSheet.cssText=css}else{style.appendChild(document.createTextNode(css))} head.appendChild(style)}();$self.find(".sbi_photo").sbi_imgLiquid({fill:!0})} var sbi_delay=(function(){var sbi_timer=0;return function(sbi_callback,sbi_ms){clearTimeout(sbi_timer);sbi_timer=setTimeout(sbi_callback,sbi_ms)}})();jQuery(window).resize(function(){sbi_delay(function(){sbiSetPhotoHeight()},500)});function sbiSetPhotoHeight(){if(imgRes!=='thumbnail'){var sbi_photo_width=$self.find('.sbi_photo').eq(0).innerWidth();var sbi_num_cols=parseInt(cols);if(!$self.hasClass('sbi_disable_mobile')){var sbiWindowWidth=jQuery(window).width();if(sbiWindowWidth<640&&(parseInt(cols)>2&&parseInt(cols)<7))sbi_num_cols=2;if(sbiWindowWidth<640&&(parseInt(cols)>6&&parseInt(cols)<11))sbi_num_cols=4;if(sbiWindowWidth<=480&&parseInt(cols)>2)sbi_num_cols=1} var sbi_photo_width_manual=($self.find('#sbi_images').width()/sbi_num_cols)-(feedOptions.imagepadding*2);if(sbi_photo_width<=(sbi_photo_width_manual))sbi_photo_width=sbi_photo_width_manual;$self.find('.sbi_photo').css('height',sbi_photo_width)}} sbiSetPhotoHeight();!function(i){var n={callback:function(){},runOnLoad:!0,frequency:100,sbiPreviousVisibility:null},c={};c.sbiCheckVisibility=function(i,n){if(jQuery.contains(document,i[0])){var e=n.sbiPreviousVisibility,t=i.is(":visible");n.sbiPreviousVisibility=t,null==e?n.runOnLoad&&n.callback(i,t):e!==t&&n.callback(i,t),setTimeout(function(){c.sbiCheckVisibility(i,n)},n.frequency)}},i.fn.sbiVisibilityChanged=function(e){var t=i.extend({},n,e);return this.each(function(){c.sbiCheckVisibility(i(this),t)})}}(jQuery);jQuery(".sbi").filter(':hidden').sbiVisibilityChanged({callback:function(element,visible){sbiSetPhotoHeight()},runOnLoad:!1});jQuery('#sb_instagram .sbi_photo').each(function(){$sbi_photo=jQuery(this);$sbi_photo.hover(function(){jQuery(this).fadeTo(200,0.85)},function(){jQuery(this).stop().fadeTo(500,1)});if($sbi_photo.closest('.sbi_item').hasClass('sbi_type_video')){if(!$sbi_photo.find('.sbi_playbtn').length)$sbi_photo.append('')}});$self.find('#sbi_images .sbi_item.sbi_new').sort(function(a,b){var aComp=jQuery(a).data('date'),bComp=jQuery(b).data('date');if(sortby=='none'){return bComp-aComp}else{return(Math.round(Math.random())-0.5)}}).appendTo($self.find("#sbi_images"));setTimeout(function(){jQuery('#sbi_images .sbi_item.sbi_new').removeClass('sbi_new');morePosts=[]},500);function sbiGetItemSize(){$self.removeClass('sbi_small sbi_medium');var sbiItemWidth=$self.find('.sbi_item').innerWidth();if(sbiItemWidth>120&&sbiItemWidth<240){$self.addClass('sbi_medium')}else if(sbiItemWidth<=120){$self.addClass('sbi_small')}} sbiGetItemSize()},error:function(data){var sbiErrorMsg='',sbiErrorDir='';if(data.indexOf('access_token')>-1){sbiErrorMsg+='

Error: Access Token is not valid
This error message is only visible to WordPress admins';sbiErrorDir="

There's an issue with the Instagram Access Token that you are using. Please obtain a new Access Token on the plugin's Settings page.
If you continue to have an issue with your Access Token then please see this FAQ for more information."}else if(data.indexOf('user does not exist')>-1){sbiErrorMsg+='

Error: The User ID does not exist
This error is only visible to WordPress admins';sbiErrorDir="

Please double check the Instagram User ID that you are using. To find your User ID simply enter your Instagram user name into this tool.

"} if(looparray.length<2)jQuery('#sb_instagram').empty().append('

Unable to show Instagram photos

'+sbiErrorMsg+sbiErrorDir+'
')}});$loadBtn.click(function(){userFeed.next()});userFeed.run()})})} jQuery(document).ready(function(){sbi_init()})}; jQuery(document).ready(function($){ var overlay, comments, gallery, container, nextButton, previousButton, info, transitionBegin, caption, resizeTimeout, photo_info, close_hint, commentInterval, lastSelectedSlide, screenPadding=110, originalOverflow=$('body').css('overflow'), originalHOverflow=$('html').css('overflow'), proportion=85, last_known_location_hash='', imageMeta, titleAndDescription, commentForm, leftColWrapper, scrollPos; if(window.innerWidth <=760){ screenPadding=Math.round(( window.innerWidth / 760) * 110); if(screenPadding < 40&&(( 'ontouchstart' in window)||window.DocumentTouch&&document instanceof DocumentTouch)){ screenPadding=0; }} if('undefined'===typeof Date.now){ Date.now=function now(){ return new Date().getTime(); };} var keyListener=function(e){ switch(e.which){ case 38: e.preventDefault(); container.scrollTop(container.scrollTop() - 100); break; case 40: e.preventDefault(); container.scrollTop(container.scrollTop() + 100); break; case 39: e.preventDefault(); gallery.jp_carousel('clearCommentTextAreaValue'); gallery.jp_carousel('next'); break; case 37: case 8: e.preventDefault(); gallery.jp_carousel('clearCommentTextAreaValue'); gallery.jp_carousel('previous'); break; case 27: e.preventDefault(); gallery.jp_carousel('clearCommentTextAreaValue'); container.jp_carousel('close'); break; default: break; }}; var resizeListener=function(){ clearTimeout(resizeTimeout); resizeTimeout=setTimeout(function(){ gallery .jp_carousel('slides') .jp_carousel('fitSlide', true); gallery.jp_carousel('updateSlidePositions', true); gallery.jp_carousel('fitMeta', true); }, 200); }; var prepareGallery=function(){ if(!overlay){ overlay=$('
') .addClass('jp-carousel-overlay') .css({ 'position':'absolute', 'top':0, 'right':0, 'bottom':0, 'left':0 }); var buttons=''; if(1===Number(jetpackCarouselStrings.is_logged_in)){ } buttons=$(''); caption=$('

'); photo_info=$('').append(caption); imageMeta=$('
') .addClass('jp-carousel-image-meta') .css({ 'float':'right', 'margin-top':'20px', 'width':'250px' }); imageMeta .append(buttons) .append('') .append('') .append(''); titleAndDescription=$('
') .addClass('jp-carousel-titleanddesc') .css({ 'width':'100%', 'margin-top':imageMeta.css('margin-top') }); var commentFormMarkup=''; commentForm=$(commentFormMarkup) .css({ 'width':'100%', 'margin-top':'20px', 'color':'#999' }); comments=$('
') .addClass('jp-carousel-comments') .css({ 'width':'100%', 'bottom':'10px', 'margin-top':'20px' }); var commentsLoading=$('') .css({ 'width':'100%', 'bottom':'10px', 'margin-top':'20px' }); var leftWidth=($(window).width() -(screenPadding * 2)) - (imageMeta.width() + 40); leftWidth +='px'; leftColWrapper=$('
') .addClass('jp-carousel-left-column-wrapper') .css({ 'width':Math.floor(leftWidth) }) .append(titleAndDescription) .append(commentForm) .append(comments) .append(commentsLoading); var fadeaway=$('
') .addClass('jp-carousel-fadeaway'); info=$('
') .addClass('jp-carousel-info') .css({ 'top':Math.floor(($(window).height() / 100) * proportion), 'left':screenPadding, 'right':screenPadding }) .append(photo_info) .append(imageMeta); if(window.innerWidth <=760){ photo_info.remove().insertAfter(titleAndDescription); info.prepend(leftColWrapper); }else{ info.append(leftColWrapper); } var targetBottomPos=($(window).height() - parseInt(info.css('top'), 10)) + 'px'; nextButton=$('
') .addClass('jp-carousel-next-button') .css({ 'right':'15px' }); previousButton=$('
') .addClass('jp-carousel-previous-button') .css({ 'left':0 }); nextButton.add(previousButton).css({ 'position':'fixed', 'top':'40px', 'bottom':targetBottomPos, 'width':screenPadding }); gallery=$('
') .addClass('jp-carousel') .css({ 'position':'absolute', 'top':0, 'bottom':targetBottomPos, 'left':0, 'right':0 }); close_hint=$('') .css({ position:'fixed' }); container=$('
') .addClass('jp-carousel-wrap') .addClass('jp-carousel-transitions'); if('white'===jetpackCarouselStrings.background_color){ container.addClass('jp-carousel-light'); } container.attr('itemscope', ''); container.attr('itemtype', 'https://schema.org/ImageGallery'); container.css({ 'position':'fixed', 'top':0, 'right':0, 'bottom':0, 'left':0, 'z-index':2147483647, 'overflow-x':'hidden', 'overflow-y':'auto', 'direction':'ltr' }) .hide() .append(overlay) .append(gallery) .append(fadeaway) .append(info) .append(nextButton) .append(previousButton) .append(close_hint) .appendTo($('body')) .click(function(e){ var target=$(e.target), wrap=target.parents('div.jp-carousel-wrap'), data=wrap.data('carousel-extra'), slide=wrap.find('div.selected'), attachment_id=slide.data('attachment-id'); data=data||[]; if(target.is(gallery)||target.parents().add(target).is(close_hint)){ container.jp_carousel('close'); }else if(target.hasClass('jp-carousel-commentlink')){ e.preventDefault(); e.stopPropagation(); $(window).unbind('keydown', keyListener); container.animate({scrollTop: parseInt(info.position()['top'], 10)}, 'fast'); $('#jp-carousel-comment-form-submit-and-info-wrapper').slideDown('fast'); $('#jp-carousel-comment-form-comment-field').focus(); }else if(target.hasClass('jp-carousel-comment-login')){ var url=jetpackCarouselStrings.login_url + '%23jp-carousel-' + attachment_id; window.location.href=url; }else if(target.parents('#jp-carousel-comment-form-container').length){ var textarea=$('#jp-carousel-comment-form-comment-field') .blur(function(){ $(window).bind('keydown', keyListener); }) .focus(function(){ $(window).unbind('keydown', keyListener); }); var emailField=$('#jp-carousel-comment-form-email-field') .blur(function(){ $(window).bind('keydown', keyListener); }) .focus(function(){ $(window).unbind('keydown', keyListener); }); var authorField=$('#jp-carousel-comment-form-author-field') .blur(function(){ $(window).bind('keydown', keyListener); }) .focus(function(){ $(window).unbind('keydown', keyListener); }); var urlField=$('#jp-carousel-comment-form-url-field') .blur(function(){ $(window).bind('keydown', keyListener); }) .focus(function(){ $(window).unbind('keydown', keyListener); }); if(textarea&&textarea.attr('id')===target.attr('id')){ $(window).unbind('keydown', keyListener); $('#jp-carousel-comment-form-submit-and-info-wrapper').slideDown('fast'); }else if(target.is('input[type="submit"]')){ e.preventDefault(); e.stopPropagation(); $('#jp-carousel-comment-form-spinner').spin('small', 'white'); var ajaxData={ action: 'post_attachment_comment', nonce: jetpackCarouselStrings.nonce, blog_id: data['blog_id'], id: attachment_id, comment: textarea.val() }; if(! ajaxData['comment'].length){ gallery.jp_carousel('postCommentError', {'field': 'jp-carousel-comment-form-comment-field', 'error': jetpackCarouselStrings.no_comment_text}); return; } if(1!==Number(jetpackCarouselStrings.is_logged_in)){ ajaxData['email']=emailField.val(); ajaxData['author']=authorField.val(); ajaxData['url']=urlField.val(); if(1===Number(jetpackCarouselStrings.require_name_email)){ if(! ajaxData['email'].length||! ajaxData['email'].match('@')){ gallery.jp_carousel('postCommentError', {'field': 'jp-carousel-comment-form-email-field', 'error': jetpackCarouselStrings.no_comment_email}); return; }else if(! ajaxData['author'].length){ gallery.jp_carousel('postCommentError', {'field': 'jp-carousel-comment-form-author-field', 'error': jetpackCarouselStrings.no_comment_author}); return; }} } $.ajax({ type: 'POST', url: jetpackCarouselStrings.ajaxurl, data: ajaxData, dataType: 'json', success: function(response){ if('approved'===response.comment_status){ $('#jp-carousel-comment-post-results').slideUp('fast').html('').slideDown('fast'); }else if('unapproved'===response.comment_status){ $('#jp-carousel-comment-post-results').slideUp('fast').html('').slideDown('fast'); }else{ $('#jp-carousel-comment-post-results').slideUp('fast').html('').slideDown('fast'); } gallery.jp_carousel('clearCommentTextAreaValue'); gallery.jp_carousel('getComments', {attachment_id: attachment_id, offset: 0, clear: true}); $('#jp-carousel-comment-form-button-submit').val(jetpackCarouselStrings.post_comment); $('#jp-carousel-comment-form-spinner').spin(false); }, error: function(){ gallery.jp_carousel('postCommentError', {'field': 'jp-carousel-comment-form-comment-field', 'error': jetpackCarouselStrings.comment_post_error}); return; }}); }}else if(! target.parents('.jp-carousel-info').length){ container.jp_carousel('next'); }}) .bind('jp_carousel.afterOpen', function(){ $(window).bind('keydown', keyListener); $(window).bind('resize', resizeListener); gallery.opened=true; resizeListener(); }) .bind('jp_carousel.beforeClose', function(){ var scroll=$(window).scrollTop(); $(window).unbind('keydown', keyListener); $(window).unbind('resize', resizeListener); $(window).scrollTop(scroll); }) .bind('jp_carousel.afterClose', function(){ if(window.location.hash&&history.back){ history.back(); } last_known_location_hash=''; gallery.opened=false; }) .on('transitionend.jp-carousel ', '.jp-carousel-slide', function(e){ if('transform'===e.originalEvent.propertyName){ var transitionMultiplier=(( Date.now() - transitionBegin) / 1000) / e.originalEvent.elapsedTime; container.off('transitionend.jp-carousel'); if(transitionMultiplier >=2){ $('.jp-carousel-transitions').removeClass('jp-carousel-transitions'); }} }); $('.jp-carousel-wrap').touchwipe({ wipeLeft:function(e){ e.preventDefault(); gallery.jp_carousel('next'); }, wipeRight:function(e){ e.preventDefault(); gallery.jp_carousel('previous'); }, preventDefaultEvents:false }); nextButton.add(previousButton).click(function(e){ e.preventDefault(); e.stopPropagation(); if(nextButton.is(this)){ gallery.jp_carousel('next'); }else{ gallery.jp_carousel('previous'); }}); }}; var methods={ testForData: function(gallery){ gallery=$(gallery); return !(! gallery.length||! gallery.data('carousel-extra')); }, testIfOpened: function(){ return !!('undefined'!==typeof(gallery)&&'undefined'!==typeof(gallery.opened)&&gallery.opened); }, openOrSelectSlide: function(index){ if(! $(this).jp_carousel('testIfOpened')){ $(this).jp_carousel('open', { start_index: index }); }else{ gallery.jp_carousel('selectSlideAtIndex', index); }}, open: function(options){ var settings={ 'items_selector':'.gallery-item [data-attachment-id], .tiled-gallery-item [data-attachment-id]', 'start_index': 0 }, data=$(this).data('carousel-extra'); if(!data){ return; } prepareGallery(data); if(gallery.jp_carousel('testIfOpened')){ return; } originalOverflow=$('body').css('overflow'); $('body').css('overflow', 'hidden'); originalHOverflow=$('html').css('overflow'); $('html').css('overflow', 'hidden'); scrollPos=$(window).scrollTop(); container.data('carousel-extra', data); return this.each(function(){ var $this=$(this); if(options){ $.extend(settings, options); } if(-1===settings.start_index){ settings.start_index=0; } container.trigger('jp_carousel.beforeOpen').fadeIn('fast',function(){ container.trigger('jp_carousel.afterOpen'); gallery .jp_carousel('initSlides', $this.find(settings.items_selector), settings.start_index) .jp_carousel('selectSlideAtIndex', settings.start_index); }); gallery.html(''); }); }, selectSlideAtIndex:function(index){ var slides=this.jp_carousel('slides'), selected=slides.eq(index); if(0===selected.length){ selected=slides.eq(0); } gallery.jp_carousel('selectSlide', selected, false); return this; }, close:function(){ $('body').css('overflow', originalOverflow); $('html').css('overflow', originalHOverflow); return container .trigger('jp_carousel.beforeClose') .fadeOut('fast', function(){ container.trigger('jp_carousel.afterClose'); $(window).scrollTop(scrollPos); }); }, next:function(){ var slide=gallery.jp_carousel('nextSlide'); container.animate({scrollTop:0}, 'fast'); if(slide){ this.jp_carousel('selectSlide', slide); }}, previous:function(){ var slide=gallery.jp_carousel('prevSlide'); container.animate({scrollTop:0}, 'fast'); if(slide){ this.jp_carousel('selectSlide', slide); }}, selectedSlide:function(){ return this.find('.selected'); }, setSlidePosition:function(x){ transitionBegin=Date.now(); return this.css({ '-webkit-transform':'translate3d(' + x + 'px,0,0)', '-moz-transform':'translate3d(' + x + 'px,0,0)', '-ms-transform':'translate(' + x + 'px,0)', '-o-transform':'translate(' + x + 'px,0)', 'transform':'translate3d(' + x + 'px,0,0)' }); }, updateSlidePositions:function(animate){ var current=this.jp_carousel('selectedSlide'), galleryWidth=gallery.width(), currentWidth=current.width(), previous=gallery.jp_carousel('prevSlide'), next=gallery.jp_carousel('nextSlide'), previousPrevious=previous.prev(), nextNext=next.next(), left=Math.floor(( galleryWidth - currentWidth) * 0.5); current.jp_carousel('setSlidePosition', left).show(); gallery.jp_carousel('fitInfo', animate); var direction=lastSelectedSlide.is(current.prevAll()) ? 1:-1; if(1===direction){ if(! nextNext.is(previous)){ nextNext.jp_carousel('setSlidePosition', galleryWidth + next.width()).show(); } if(! previousPrevious.is(next)){ previousPrevious.jp_carousel('setSlidePosition', -previousPrevious.width() - currentWidth).show(); }}else{ if(! nextNext.is(previous)){ nextNext.jp_carousel('setSlidePosition', galleryWidth + currentWidth).show(); }} previous.jp_carousel('setSlidePosition', Math.floor(-previous.width() +(screenPadding * 0.75))).show(); next.jp_carousel('setSlidePosition', Math.ceil(galleryWidth -(screenPadding * 0.75))).show(); }, selectSlide:function(slide, animate){ lastSelectedSlide=this.find('.selected').removeClass('selected'); var slides=gallery.jp_carousel('slides').css({ 'position': 'fixed' }), current=$(slide).addClass('selected').css({ 'position': 'relative' }), attachmentId=current.data('attachment-id'), previous=gallery.jp_carousel('prevSlide'), next=gallery.jp_carousel('nextSlide'), previousPrevious=previous.prev(), nextNext=next.next(), animated, captionHtml; gallery.jp_carousel('loadFullImage', current); caption.hide(); if(next.length===0&&slides.length <=2){ $('.jp-carousel-next-button').hide(); }else{ $('.jp-carousel-next-button').show(); } if(previous.length===0&&slides.length <=2){ $('.jp-carousel-previous-button').hide(); }else{ $('.jp-carousel-previous-button').show(); } animated=current .add(previous) .add(previousPrevious) .add(next) .add(nextNext) .jp_carousel('loadSlide'); slides.not(animated).hide(); gallery.jp_carousel('updateSlidePositions', animate); container.trigger('jp_carousel.selectSlide', [current]); gallery.jp_carousel('getTitleDesc', { title: current.data('title'), desc: current.data('desc') }); var imageMeta=current.data('image-meta'); gallery.jp_carousel('updateExif', imageMeta); gallery.jp_carousel('updateFullSizeLink', current); gallery.jp_carousel('updateMap', imageMeta); gallery.jp_carousel('testCommentsOpened', current.data('comments-opened')); gallery.jp_carousel('getComments', { 'attachment_id': attachmentId, 'offset': 0, 'clear': true }); $('#jp-carousel-comment-post-results').slideUp(); if(current.data('caption')){ captionHtml=$('
').text(current.data('caption')).html(); if(captionHtml===$('
').text(current.data('title')).html()){ $('.jp-carousel-titleanddesc-title').fadeOut('fast').empty(); } if(captionHtml===$('
').text(current.data('desc')).html()){ $('.jp-carousel-titleanddesc-desc').fadeOut('fast').empty(); } caption.html(current.data('caption')).fadeIn('slow'); }else{ caption.fadeOut('fast').empty(); } if(jetpackCarouselStrings.stats){ new Image().src=document.location.protocol + '//pixel.wp.com/g.gif?' + jetpackCarouselStrings.stats + '&post=' + encodeURIComponent(attachmentId) + '&rand=' + Math.random(); } $(next).add(previous).each(function(){ gallery.jp_carousel('loadFullImage', $(this)); }); window.location.hash=last_known_location_hash='#jp-carousel-' + attachmentId; }, slides:function(){ return this.find('.jp-carousel-slide'); }, slideDimensions:function(){ return { width: $(window).width() - (screenPadding * 2), height: Math.floor($(window).height() / 100 * proportion - 60) };}, loadSlide:function(){ return this.each(function(){ var slide=$(this); slide.find('img') .one('load', function(){ slide .jp_carousel('fitSlide',false); }); }); }, bestFit:function(){ var max=gallery.jp_carousel('slideDimensions'), orig=this.jp_carousel('originalDimensions'), orig_ratio=orig.width / orig.height, w_ratio=1, h_ratio=1, width, height; if(orig.width > max.width){ w_ratio=max.width / orig.width; } if(orig.height > max.height){ h_ratio=max.height / orig.height; } if(w_ratio < h_ratio){ width=max.width; height=Math.floor(width / orig_ratio); }else if(h_ratio < w_ratio){ height=max.height; width=Math.floor(height * orig_ratio); }else{ width=orig.width; height=orig.height; } return { width: width, height: height };}, fitInfo:function(){ var current=this.jp_carousel('selectedSlide'), size=current.jp_carousel('bestFit'); photo_info.css({ 'left':Math.floor((info.width() - size.width) * 0.5), 'width':Math.floor(size.width) }); return this; }, fitMeta:function(animated){ var newInfoTop={ top: Math.floor($(window).height() / 100 * proportion + 5) + 'px' }; var newLeftWidth={ width:(info.width() - (imageMeta.width() + 80)) + 'px' }; if(animated){ info.animate(newInfoTop); leftColWrapper.animate(newLeftWidth); }else{ info.animate(newInfoTop); leftColWrapper.css(newLeftWidth); }}, fitSlide:function(){ return this.each(function(){ var $this=$(this), dimensions=$this.jp_carousel('bestFit'), method='css', max=gallery.jp_carousel('slideDimensions'); dimensions.left=0; dimensions.top=Math.floor((max.height - dimensions.height) * 0.5) + 40; $this[method](dimensions); }); }, texturize:function(text){ text='' + text; // make sure we get a string. Title "1" came in as int 1, for example, which did not support .replace(). text=text.replace(/'/g, '’').replace(/'/g, '’').replace(/[\u2019]/g, '’'); text=text.replace(/"/g, '”').replace(/"/g, '”').replace(/"/g, '”').replace(/[\u201D]/g, '”'); text=text.replace(/([\w]+)=&#[\d]+;(.+?)&#[\d]+;/g, '$1="$2"'); return $.trim(text); }, initSlides:function(items, start_index){ if(items.length < 2){ $('.jp-carousel-next-button, .jp-carousel-previous-button').hide(); }else{ $('.jp-carousel-next-button, .jp-carousel-previous-button').show(); } items.each(function(){ var src_item=$(this), orig_size=src_item.data('orig-size')||'', max=gallery.jp_carousel('slideDimensions'), parts=orig_size.split(','), medium_file=src_item.data('medium-file')||'', large_file=src_item.data('large-file')||'', src; orig_size={width: parseInt(parts[0], 10), height: parseInt(parts[1], 10)}; src=src_item.data('orig-file'); src=gallery.jp_carousel('selectBestImageSize', { orig_file:src, orig_width:orig_size.width, orig_height:orig_size.height, max_width:max.width, max_height:max.height, medium_file:medium_file, large_file:large_file }); $(this).data('gallery-src', src); }); if(0!==start_index){ $('')[0].src=$(items[start_index]).data('gallery-src'); } var useInPageThumbnails=items.first().closest('.tiled-gallery.type-rectangular').length > 0; items.each(function(i){ var src_item=$(this), attachment_id=src_item.data('attachment-id')||0, comments_opened=src_item.data('comments-opened')||0, image_meta=src_item.data('image-meta')||{}, orig_size=src_item.data('orig-size')||'', thumb_size={ width:src_item[0].naturalWidth, height:src_item[0].naturalHeight }, title=src_item.data('image-title')||'', description=src_item.data('image-description')||'', caption=src_item.parents('.gallery-item').find('.gallery-caption').html()||'', src=src_item.data('gallery-src')||'', medium_file=src_item.data('medium-file')||'', large_file=src_item.data('large-file')||'', orig_file=src_item.data('orig-file')||''; var tiledCaption=src_item.parents('div.tiled-gallery-item').find('div.tiled-gallery-caption').html(); if(tiledCaption){ caption=tiledCaption; } if(attachment_id&&orig_size.length){ title=gallery.jp_carousel('texturize', title); description=gallery.jp_carousel('texturize', description); caption=gallery.jp_carousel('texturize', caption); var image=$('') .attr('src', 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7') .css('width', '100%') .css('height', '100%'); var slide=$('') .hide() .css({ 'left':i < start_index ? -1000:gallery.width() }) .append(image) .appendTo(gallery) .data('src', src) .data('title', title) .data('desc', description) .data('caption', caption) .data('attachment-id', attachment_id) .data('permalink', src_item.parents('a').attr('href')) .data('orig-size', orig_size) .data('comments-opened', comments_opened) .data('image-meta', image_meta) .data('medium-file', medium_file) .data('large-file', large_file) .data('orig-file', orig_file) .data('thumb-size', thumb_size) ; if(useInPageThumbnails){ slide .data('preview-image', src_item.attr('src')) .css({ 'background-image':'url("' + src_item.attr('src') + '")', 'background-size':'100% 100%', 'background-position':'center center' }); } slide.jp_carousel('fitSlide', false); }}); return this; }, selectBestImageSize: function(args){ if('object'!==typeof args){ args={};} if('undefined'===typeof args.orig_file){ return ''; } if('undefined'===typeof args.orig_width||'undefined'===typeof args.max_width){ return args.orig_file; } if('undefined'===typeof args.medium_file||'undefined'===typeof args.large_file){ return args.orig_file; } var imageLinkParser=document.createElement('a'); imageLinkParser.href=args.large_file; var isPhotonUrl=(imageLinkParser.hostname.match(/^i[\d]{1}.wp.com$/i)!=null); var medium_size_parts=gallery.jp_carousel('getImageSizeParts', args.medium_file, args.orig_width, isPhotonUrl); var large_size_parts=gallery.jp_carousel('getImageSizeParts', args.large_file, args.orig_width, isPhotonUrl); var large_width=parseInt(large_size_parts[0], 10), large_height=parseInt(large_size_parts[1], 10), medium_width=parseInt(medium_size_parts[0], 10), medium_height=parseInt(medium_size_parts[1], 10); args.orig_max_width=args.max_width; args.orig_max_height=args.max_height; if('undefined'!==typeof window.devicePixelRatio&&window.devicePixelRatio > 1){ args.max_width=args.max_width * window.devicePixelRatio; args.max_height=args.max_height * window.devicePixelRatio; } if(large_width >=args.max_width||large_height >=args.max_height){ return args.large_file; } if(medium_width >=args.max_width||medium_height >=args.max_height){ return args.medium_file; } if(isPhotonUrl){ var largeFileIndex=args.large_file.lastIndexOf('?'); var origPhotonUrl=args.large_file; if(-1!==largeFileIndex){ origPhotonUrl=args.large_file.substring(0, largeFileIndex); if(args.orig_width > args.max_width||args.orig_height > args.max_height){ origPhotonUrl +='?fit=' + args.orig_max_width + '%2C' + args.orig_max_height; }} return origPhotonUrl; } return args.orig_file; }, getImageSizeParts: function(file, orig_width, isPhotonUrl){ var size=isPhotonUrl ? file.replace(/.*=([\d]+%2C[\d]+).*$/, '$1') : file.replace(/.*-([\d]+x[\d]+)\..+$/, '$1'); var size_parts=(size!==file) ? (isPhotonUrl ? size.split('%2C'):size.split('x')) : [ orig_width, 0 ]; if('9999'===size_parts[0]){ size_parts[0]='0'; } if('9999'===size_parts[1]){ size_parts[1]='0'; } return size_parts; }, originalDimensions: function(){ var splitted=$(this).data('orig-size').split(','); return {width: parseInt(splitted[0], 10), height: parseInt(splitted[1], 10)};}, format: function(args){ if('object'!==typeof args){ args={};} if(! args.text||'undefined'===typeof args.text){ return; } if(! args.replacements||'undefined'===typeof args.replacements){ return args.text; } return args.text.replace(/{(\d+)}/g, function(match, number){ return typeof args.replacements[number]!=='undefined' ? args.replacements[number]:match; }); }, shutterSpeed: function(speed){ var denominator; if(speed >=1){ return Math.round(speed * 10) / 10 + 's'; } denominator=Math.round(1 / speed); return '1/' + denominator + 's'; }, parseTitleDesc: function(value){ if(!value.match(' ')&&value.match('_')){ return ''; } $([ 'CIMG', 'DSC_', 'DSCF', 'DSCN', 'DUW', 'GEDC', 'IMG', 'JD', 'MGP', 'PICT', 'Imagen', 'Foto', 'DSC', 'Scan', 'SANY', 'SAM', 'Screen Shot [0-9]+' ]) .each(function(key, val){ var regex=new RegExp('^' + val); if(regex.test(value)){ value=''; return; }}); return value; }, getTitleDesc: function(data){ var title='', desc='', markup='', target; target=$('div.jp-carousel-titleanddesc', 'div.jp-carousel-wrap'); target.hide(); title=gallery.jp_carousel('parseTitleDesc', data.title)||''; desc=gallery.jp_carousel('parseTitleDesc', data.desc)||''; if(title.length||desc.length){ if($('
').html(title).text()===$('
').html(desc).text()){ title=''; } markup=(title.length) ? '':''; markup +=(desc.length) ? '':''; target.html(markup).fadeIn('slow'); } $('div#jp-carousel-comment-form-container').css('margin-top', '20px'); $('div#jp-carousel-comments-loading').css('margin-top', '20px'); }, updateExif: function(meta){ if(!meta||1!==Number(jetpackCarouselStrings.display_exif)){ return false; } var $ul=$(''); $.each(meta, function(key, val){ if(0===parseFloat(val)||!val.length||-1===$.inArray(key, [ 'camera', 'aperture', 'shutter_speed', 'focal_length' ])){ return; } switch(key){ case 'focal_length': val=val + 'mm'; break; case 'shutter_speed': val=gallery.jp_carousel('shutterSpeed', val); break; case 'aperture': val='f/' + val; break; } $ul.append('
  • ' + jetpackCarouselStrings[key] + '
    ' + val + '
  • '); }); $('div.jp-carousel-image-meta ul.jp-carousel-image-exif').replaceWith($ul); }, updateFullSizeLink: function(current){ if(!current||!current.data){ return false; } var original, origSize=current.data('orig-size').split(','), imageLinkParser=document.createElement('a'); imageLinkParser.href=current.data('src').replace(/\?.+$/, ''); if(imageLinkParser.hostname.match(/^i[\d]{1}.wp.com$/i)!==null){ original=imageLinkParser.href; }else{ original=current.data('orig-file').replace(/\?.+$/, ''); } var permalink=$(''+gallery.jp_carousel('format', {'text': jetpackCarouselStrings.download_original, 'replacements': origSize})+'') .addClass('jp-carousel-image-download') .attr('href', original) .attr('target', '_blank'); $('div.jp-carousel-image-meta a.jp-carousel-image-download').replaceWith(permalink); }, updateMap: function(meta){ if(!meta.latitude||!meta.longitude||1!==Number(jetpackCarouselStrings.display_geo)){ return; } var latitude=meta.latitude, longitude=meta.longitude, $metabox=$('div.jp-carousel-image-meta', 'div.jp-carousel-wrap'), $mapbox=$('
    '), style='&scale=2&style=feature:all|element:all|invert_lightness:true|hue:0x0077FF|saturation:-50|lightness:-5|gamma:0.91'; $mapbox .addClass('jp-carousel-image-map') .html('\ \
    \ \ ') .prependTo($metabox); }, testCommentsOpened: function(opened){ if(1===parseInt(opened, 10)){ $('.jp-carousel-buttons').fadeIn('fast'); commentForm.fadeIn('fast'); }else{ $('.jp-carousel-buttons').fadeOut('fast'); commentForm.fadeOut('fast'); }}, getComments: function(args){ clearInterval(commentInterval); if('object'!==typeof args){ return; } if('undefined'===typeof args.attachment_id||! args.attachment_id){ return; } if(! args.offset||'undefined'===typeof args.offset||args.offset < 1){ args.offset=0; } var comments=$('.jp-carousel-comments'), commentsLoading=$('#jp-carousel-comments-loading').show(); if(args.clear){ comments.hide().empty(); } $.ajax({ type: 'GET', url: jetpackCarouselStrings.ajaxurl, dataType: 'json', data: { action: 'get_attachment_comments', nonce: jetpackCarouselStrings.nonce, id: args.attachment_id, offset: args.offset }, success: function(data){ if(args.clear){ comments.fadeOut('fast').empty(); } $(data).each(function(){ var comment=$('
    ') .addClass('jp-carousel-comment') .attr('id', 'jp-carousel-comment-' + this['id']) .html('
    ' + this['gravatar_markup'] + '
    ' + '
    ' + this['author_markup'] + '
    ' + '
    ' + this['date_gmt'] + '
    ' + '
    ' + this['content'] + '
    ' ); comments.append(comment); clearInterval(commentInterval); commentInterval=setInterval(function(){ if(( $('.jp-carousel-overlay').height() - 150) < $('.jp-carousel-wrap').scrollTop() + $(window).height()){ gallery.jp_carousel('getComments',{ attachment_id: args.attachment_id, offset: args.offset + 10, clear: false }); clearInterval(commentInterval); }}, 300); }); var current=$('.jp-carousel div.selected'); if(current&¤t.data&¤t.data('attachment-id')!=args.attachment_id){ comments.fadeOut('fast'); comments.empty(); return; } $('.jp-carousel-overlay').height($(window).height() + titleAndDescription.height() + commentForm.height() +((comments.height() > 0) ? comments.height():imageMeta.height()) + 200); comments.show(); commentsLoading.hide(); }, error: function(xhr, status, error){ console.log('Comment get fail...', xhr, status, error); comments.fadeIn('fast'); commentsLoading.fadeOut('fast'); }}); }, postCommentError: function(args){ if('object'!==typeof args){ args={};} if(! args.field||'undefined'===typeof args.field||! args.error||'undefined'===typeof args.error){ return; } $('#jp-carousel-comment-post-results').slideUp('fast').html('').slideDown('fast'); $('#jp-carousel-comment-form-spinner').spin(false); }, setCommentIframeSrc: function(attachment_id){ var iframe=$('#jp-carousel-comment-iframe'); if(iframe&&iframe.length){ iframe.attr('src', iframe.attr('src').replace(/(postid=)\d+/, '$1'+attachment_id)); iframe.attr('src', iframe.attr('src').replace(/(%23.+)?$/, '%23jp-carousel-'+attachment_id)); }}, clearCommentTextAreaValue: function(){ var commentTextArea=$('#jp-carousel-comment-form-comment-field'); if(commentTextArea){ commentTextArea.val(''); }}, nextSlide:function (){ var slides=this.jp_carousel('slides'); var selected=this.jp_carousel('selectedSlide'); if(selected.length===0||(slides.length > 2&&selected.is(slides.last()))){ return slides.first(); } return selected.next(); }, prevSlide:function (){ var slides=this.jp_carousel('slides'); var selected=this.jp_carousel('selectedSlide'); if(selected.length===0||(slides.length > 2&&selected.is(slides.first()))){ return slides.last(); } return selected.prev(); }, loadFullImage:function(slide){ var image=slide.find('img:first'); if(! image.data('loaded')){ image.on('load.jetpack', function (){ image.off('load.jetpack'); $(this).closest('.jp-carousel-slide').css('background-image', ''); }); if(! slide.data('preview-image')||(slide.data('thumb-size')&&slide.width() > slide.data('thumb-size').width)){ image.attr('src', image.closest('.jp-carousel-slide').data('src')).attr('itemprop', 'image'); }else{ image.attr('src', slide.data('preview-image')).attr('itemprop', 'image'); } image.data('loaded', 1); }} }; $.fn.jp_carousel=function(method){ if(methods[method]){ return methods[ method ].apply(this, Array.prototype.slice.call(arguments, 1)); }else if(typeof method==='object'||! method){ return methods.open.apply(this, arguments); }else{ $.error('Method ' + method + ' does not exist on jQuery.jp_carousel'); }}; $(document.body).on('click.jp-carousel', 'div.gallery,div.tiled-gallery', function(e){ if(! $(this).jp_carousel('testForData', e.currentTarget)){ return; } if($(e.target).parent().hasClass('gallery-caption')){ return; } e.preventDefault(); e.stopPropagation(); $(this).jp_carousel('open', {start_index: $(this).find('.gallery-item, .tiled-gallery-item').index($(e.target).parents('.gallery-item, .tiled-gallery-item'))}); }); $(window).on('hashchange.jp-carousel', function (){ var hashRegExp=/jp-carousel-(\d+)/, matches, attachmentId, galleries, selectedThumbnail; if(! window.location.hash||! hashRegExp.test(window.location.hash)){ if(gallery&&gallery.opened){ container.jp_carousel('close'); } return; } if(( window.location.hash===last_known_location_hash)&&gallery.opened){ return; } if(window.location.hash&&gallery&&!gallery.opened&&history.back){ history.back(); return; } last_known_location_hash=window.location.hash; matches=window.location.hash.match(hashRegExp); attachmentId=parseInt(matches[1], 10); galleries=$('div.gallery, div.tiled-gallery'); galleries.each(function(_, galleryEl){ $(galleryEl).find('img').each(function(imageIndex, imageEl){ if($(imageEl).data('attachment-id')===parseInt(attachmentId, 10)){ selectedThumbnail={ index: imageIndex, gallery: galleryEl }; return false; }}); if(selectedThumbnail){ $(selectedThumbnail.gallery) .jp_carousel('openOrSelectSlide', selectedThumbnail.index); }}); }); if(window.location.hash){ $(window).trigger('hashchange'); }}); (function($){ $.fn.touchwipe=function(settings){ var config={ min_move_x: 20, min_move_y: 20, wipeLeft: function(){ }, wipeRight: function(){ }, wipeUp: function(){ }, wipeDown: function(){ }, preventDefaultEvents: true }; if(settings){ $.extend(config, settings); } this.each(function(){ var startX; var startY; var isMoving=false; function cancelTouch(){ this.removeEventListener('touchmove', onTouchMove); startX=null; isMoving=false; } function onTouchMove(e){ if(config.preventDefaultEvents){ e.preventDefault(); } if(isMoving){ var x=e.touches[0].pageX; var y=e.touches[0].pageY; var dx=startX - x; var dy=startY - y; if(Math.abs(dx) >=config.min_move_x){ cancelTouch(); if(dx > 0){ config.wipeLeft(e); }else{ config.wipeRight(e); }} else if(Math.abs(dy) >=config.min_move_y){ cancelTouch(); if(dy > 0){ config.wipeDown(e); }else{ config.wipeUp(e); }} }} function onTouchStart(e){ if(e.touches.length===1){ startX=e.touches[0].pageX; startY=e.touches[0].pageY; isMoving=true; this.addEventListener('touchmove', onTouchMove, false); }} if('ontouchstart' in document.documentElement){ this.addEventListener('touchstart', onTouchStart, false); }}); return this; };})(jQuery);